<html>
<head><meta charset="utf-8"><title>provenance through integers? · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance.20through.20integers.3F.html">provenance through integers?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="172567806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance%20through%20integers%3F/near/172567806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance.20through.20integers.3F.html#172567806">(Aug 06 2019 at 08:00)</a>:</h4>
<p>See <a href="https://github.com/rust-lang/rust/pull/63297#pullrequestreview-271172547" target="_blank" title="https://github.com/rust-lang/rust/pull/63297#pullrequestreview-271172547">https://github.com/rust-lang/rust/pull/63297#pullrequestreview-271172547</a> : I thought there was pretty much consensus that our integers do not have provenance, hence I wrote a note along those lines some time ago and it is in the <code>wrapping_offset</code> docs these days. Was I moving too quick?</p>



<a name="172573071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance%20through%20integers%3F/near/172573071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance.20through.20integers.3F.html#172573071">(Aug 06 2019 at 09:31)</a>:</h4>
<blockquote>
<p>Was I moving too quick?</p>
</blockquote>
<p>IIUC from the LLVM bug, LLVM does not support this yet, and it still miscompiles programs.</p>



<a name="172573084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance%20through%20integers%3F/near/172573084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance.20through.20integers.3F.html#172573084">(Aug 06 2019 at 09:32)</a>:</h4>
<p>Although it appears that the intent is to support this at some point</p>



<a name="172573298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance%20through%20integers%3F/near/172573298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance.20through.20integers.3F.html#172573298">(Aug 06 2019 at 09:34)</a>:</h4>
<p>There are some safe Rust programs that get "miscompiled" due to this, but I am not sure whether these are miscompilations or not</p>



<a name="172579417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance%20through%20integers%3F/near/172579417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance.20through.20integers.3F.html#172579417">(Aug 06 2019 at 11:21)</a>:</h4>
<p>I also don't think anyone wants integers to carry pointer provenance in Rust, but given that there hasn't been a formal decision (e.g., by T-lang) and there are reasonable concerns about whether LLVM supports/will support that, we should probably be conservative in libstd docs, just as we are w.r.t. things like uninitialized integers.</p>



<a name="172602023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance%20through%20integers%3F/near/172602023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance.20through.20integers.3F.html#172602023">(Aug 06 2019 at 16:00)</a>:</h4>
<p>but what else would we tell people that ask for cross-object arithmetic? "not possible"? I fear if we do that, they'll use <code>wrapping_offset</code> as that's just so much easier to use.</p>



<a name="172637678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance%20through%20integers%3F/near/172637678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance.20through.20integers.3F.html#172637678">(Aug 06 2019 at 23:27)</a>:</h4>
<blockquote>
<p>not possible"?</p>
</blockquote>
<p>Due to the current bugs, can we tell them that it is possible?</p>



<a name="172637740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance%20through%20integers%3F/near/172637740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance.20through.20integers.3F.html#172637740">(Aug 06 2019 at 23:28)</a>:</h4>
<p>I don't want integers to carry provenance, but I don't think there is a reliable way to do this in Rust (or C or C++) today</p>



<a name="172657897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance%20through%20integers%3F/near/172657897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance.20through.20integers.3F.html#172657897">(Aug 07 2019 at 08:06)</a>:</h4>
<p>I am not disagreeing. I am just saying I think the alternative is that people will do it anyway, and will notice it seems to work -- and they'll not e as conservative as they should be so even if the LLVM devs fix their stuff one day, this code will still be wrong.</p>



<a name="172662651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance%20through%20integers%3F/near/172662651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance.20through.20integers.3F.html#172662651">(Aug 07 2019 at 09:24)</a>:</h4>
<p>It's an ungreat situation. Perhaps we can document the ptrtoint way as "not decided, may still be UB, but if anything will ever work it'll be this"</p>



<a name="172746712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance%20through%20integers%3F/near/172746712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance.20through.20integers.3F.html#172746712">(Aug 08 2019 at 08:13)</a>:</h4>
<p>"ungreat", heh ;)</p>



<a name="172746719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance%20through%20integers%3F/near/172746719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance.20through.20integers.3F.html#172746719">(Aug 08 2019 at 08:13)</a>:</h4>
<p>do you want to give a shot at updating the docs that way?</p>



<a name="172747111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance%20through%20integers%3F/near/172747111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance.20through.20integers.3F.html#172747111">(Aug 08 2019 at 08:21)</a>:</h4>
<p>I don't think it'll be high priority enough for me to get to it soon-ish</p>



<a name="172747171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance%20through%20integers%3F/near/172747171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/provenance.20through.20integers.3F.html#172747171">(Aug 08 2019 at 08:22)</a>:</h4>
<p>fair.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>